home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-08 | 58.9 KB | 1,531 lines |
- ; $Id: d_surfview.pro,v 1.23 1997/04/23 02:42:04 tremblay Exp $
- ;
- ; Copyright (c) 1997, Research Systems, Inc. All rights reserved.
- ; Unauthorized reproduction prohibited.
- ;
- ;+
- ; FILE:
- ; d_surfview.pro
- ;
- ; CALLING SEQUENCE: d_surfview
- ;
- ; PURPOSE:
- ; This application shows the IDL 5.0 functionalities of a surface.
- ;
- ; MAJOR TOPICS: Visualization
- ;
- ; CATEGORY:
- ; IDL 5.0
- ;
- ; INTERNAL FUNCTIONS and PROCEDURES:
- ; fun wsu_ToggleOffOn - Toggle between 'off' and 'on'
- ; pro wsu_AnimateSurface50 - Animate the surface
- ; pro wsu_AddTracePoint - Add a tracing point
- ; pro wsu_Surfview50_Event - Event handler
- ; pro surfview_Cleanup - Cleanup
- ; pro wsu_Surfview50 - Main procedure
- ;
- ; EXTERNAL FUNCTIONS, PROCEDURES, and FILES:
- ; pro trackball__define - Create the trackball object
- ; fun gettips - Read the tip file
- ; pro widtips - Create the text widgets for tip
- ; pro sizetips - Size the text widgets for tip
- ; pro puttips - Cahnge the tip text
- ; surfview.txt
- ;
- ; REFERENCE: IDL Reference Guide, IDL User's Guide
- ;
- ; NAMED STRUCTURES:
- ; none.
- ;
- ; COMMON BLOCS:
- ; none.
- ;
- ; MODIFICATION HISTORY:
- ; 9/96, DD - Written.
- ; 10/96, DAT - New GUI.
- ;-
- ;----------------------------------------------------------------------------
- ;
- ; Purpose : Toggle the string 'off' and 'on' of a widget name.
- ; Function returns -1 on failure, 0 on 'off', 1 on 'on'.
- ;
- function wsu_ToggleOffOn, $
- widgetID ; IN: widget identifier for which its value is the name
-
- WIDGET_CONTROL, widgetID, GET_VALUE=name
-
- ; Toggle the 'off' and 'on' strings.
- ; Otherwise, the function retuns -1.
- ;
- offPosition = STRPOS(name, '(off)')
- if (offPosition ne -1) then begin
- STRPUT, name, '(on )', offPosition
- returnFlag = 1
- endif else begin
- onPosition = STRPOS(name, '(on )')
- if (onPosition ne -1) then begin
- STRPUT, name, '(off)', onPosition
- returnFlag = 0
- endif else begin
- returnFlag = -1
- endelse
- endelse
-
- WIDGET_CONTROL, widgetID, SET_VALUE=name
-
- RETURN, returnFlag
-
- end
-
- ;----------------------------------------------------------------------------
- ;
- ; Purpose: Animate the surface object.
- ;
- pro wsu_AnimateSurface, $
- sState, $ ; IN: sState structure
- scenario ; IN: index indicating the specified animation
-
- ; Get the x and y dimension of the surface object.
- ;
- xdim = sState.xSizeData
- ydim = sState.ySizeData
-
- case scenario of
-
- ; This animation deforms the middle of the surface back an forth
- ; by translating the x and y coordinates.
- ;
- 0 : begin
- x = FLTARR(xdim, ydim)
- for i = 0, 10 do begin
- floatIndex = FLOAT(i)
- for j = 0, xdim-1 do x(j, *) = j
- for j = 0, ydim-1 do x(*, j) = x(*,j) $
- + floatIndex*SIN(j*(!PI/20.0))
- sState.oSurface->SetProperty, DATAX = x
- sState.oWindow->Draw, sState.oView
- endfor
- for i = 9, 0, -1 do begin
- floatIndex = FLOAT(i)
- for j = 0, xdim-1 do x(j, *) = j
- for j = 0, ydim-1 do x(*, j) = x(*,j) $
- + floatIndex*SIN(j*(!pi/20.0))
- sState.oSurface->SetProperty, DATAX=x
- sState.oWindow->Draw, sState.oView
- endfor
- end ; of 1
-
- endcase
-
- end ; of Animate
-
- ;----------------------------------------------------------------------------
- ;
- ; Purpose: Add a data point to the trace path.
- ;
- pro wsu_AddTracePoint, $
- oTrace, $ ; IN: polyline object of the trace
- xyzVector, $ ; IN: x, y, z, vector of the new data point
- status ; OUT: -1: failure, 1: success
-
- ; Verify the validity of oTrace.
- ;
- if (OBJ_VALID(oTrace) eq 0 ) then begin
- PRINT,'Error in wsu_AddTracePoint: invalid trace polyline object.'
- status = -1
- RETURN
- endif
-
- ; Verify that xyzVector contains 3 elements.
- ;
- sizexyz = SIZE(xyzVector)
- if ((sizexyz(1) ne 3)) then begin
- PRINT,'Error in wsu_AddTracePoint:'
- PRINT,'The dimension of xyzVector must be 3.'
- status = -1
- RETURN
- endif
-
- ; Get the size of data and the current number of points.
- ;
- oTrace->GetProperty, DATA=data, POLYLINE=connectivityList
- sizeData = size(data)
- nCurrentPoints = connectivityList(0)
-
- ; Return if the number of points exceeds the data size.
- ;
- if (nCurrentPoints GT sizeData(2)-2) then begin
- PRINT,'Error in wsu_AddTracePoint:'
- PRINT,'The number of data points exceeds the dimension of data'
- status = -1
- RETURN
- endif
-
- ; Add the data point.
- ;
- data(0,nCurrentPoints) = xyzVector(0)
- data(1,nCurrentPoints) = xyzVector(1)
- data(2,nCurrentPoints) = xyzVector(2)
- connectivityList(nCurrentPoints+1) = nCurrentPoints
- connectivityList(nCurrentPoints+2) = -1
- connectivityList(0) = nCurrentPoints + 1
- oTrace->SetProperty, DATA=data, POLYLINE=connectivityList
-
- status = 1
-
- end ; of wsu_AddDataPoint
-
- ;----------------------------------------------------------------------------
- ;
- ; Purpose: Handle the event.
- ;
- pro surfview50_event, $
- sEvent ; IN: event structure
-
- ; Quit the application using the close box.
- ;
- if (TAG_NAMES(sEvent, /STRUCTURE_NAME) EQ $
- 'WIDGET_KILL_REQUEST') then begin
- WIDGET_CONTROL, sEvent.top, /DESTROY
- RETURN
- endif
-
- WIDGET_CONTROL, sEvent.id, GET_UVAL=uval
-
- case uval of
-
- ; Animate the surface accordingly to scenario number 0.
- ;
- 'ANIMATE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- wsu_AnimateSurface, sState, 0
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of ANIMATE
-
- ; Change the font.
- ;
- 'FONT' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- case sEvent.index of
- 0: sState.oFont->SetProperty, NAME='Helvetica'
- 1: sState.oFont->SetProperty, NAME='Times'
- 2: begin
- if (!VERSION.OS_FAMILY eq "Windows") then $
- sState.oFont->SetProperty, NAME='Courier New' $
- else sState.oFont->SetProperty, NAME='Courier'
- end ; of case 2
- endcase
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of FONT
-
- ; Set the shading to flat.
- ;
- 'FLAT' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- sState.oSurface->SetProperty, SHADING=0
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wFlatButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wGouraudButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of FLAT
-
- ; Set the shading to gouraud.
- ;
- 'GOURAUD' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- sState.oSurface->SetProperty, SHADING=1
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wFlatButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wGouraudButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of GOURAUD
-
- ; Set the style to point.
- ;
- 'POINT' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
- sState.oSurface->SetProperty, STYLE=0
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wPointButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of POINT
-
- ; Set the style to wire.
- ;
- 'WIRE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
- sState.oSurface->SetProperty, STYLE=1
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wWireButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of POINT
-
- ; Set the style to solid.
- ;
- 'SOLID' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oSurface->SetProperty, STYLE=2
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SOLID
-
- ; Set the style to ruled xz.
- ;
- 'RULEDXZ' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
- sState.oSurface->SetProperty, STYLE=3
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of RULEDXZ
-
- ; Set the style to ruled yz.
- ;
- 'RULEDYZ' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
- sState.oSurface->SetProperty, STYLE=4
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of RULEDYZ
-
- ; Set the style to lego wire.
- ;
- 'LEGOWIRE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
- sState.oSurface->SetProperty, STYLE=5
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of LEGOWIRE
-
- ; Set the style to lego solid.
- ;
- 'LEGOSOLID' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
- sState.oSurface->SetProperty, STYLE=6
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of LEGOSOLID
-
- ; Set minimum value.
- ;
- 'SHOWMIN': begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- WIDGET_CONTROL, sState.wMinSlider, GET_VALUE=min
- WIDGET_CONTROL, sState.wMaxSlider, GET_VALUE=max
-
- min = FLOAT(min) / 100.0
- max = FLOAT(max) / 100.0
- minString = 'Minimum: ' + STRING(min, FORMAT='(f5.2)')
- WIDGET_CONTROL, sState.wMinLabel, $
- SET_VALUE=minString
-
- sState.oSurface->SetProperty, MIN_VALUE=min
- sState.oSurface->SetProperty, MAX_VALUE=max
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SHOWMIN
-
- ; Set maximum value.
- ;
- 'SHOWMAX': begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- WIDGET_CONTROL, sState.wMinSlider, GET_VALUE=min
- WIDGET_CONTROL, sState.wMaxSlider, GET_VALUE=max
- min = FLOAT(min) / 100.0
- max = FLOAT(max) / 100.0
- maxString = 'Maximum: ' + STRING(max, FORMAT='(f5.2)')
- WIDGET_CONTROL, sState.wMaxLabel, $
- SET_VALUE=maxString
-
- sState.oSurface->SetProperty, MIN_VALUE=min
- sState.oSurface->SetProperty, MAX_VALUE=max
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SHOWMAX
-
- ; Set scaling
- ;
- 'SCALING': begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- WIDGET_CONTROL, sState.wScalingSlider, GET_VALUE=scale
-
- scale = 0.75 + FLOAT(scale) / 100.0
- scalep = scale*100.0
- scalingString = 'Scaling : ' + STRING(scalep, $
- FORMAT='(f5.1)') + ' %'
- WIDGET_CONTROL, sState.wScalingLabel, $
- SET_VALUE=scalingString
-
- transform = [[scale, 0, 0, 0.0], [0, scale, 0, 0.0], $
- [0, 0, scale, 0.0], [0, 0, 0, 1]]
- sState.oMovableScalingModel->SetProperty, TRANSFORM=transform
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SCALING
-
- ; Reset the initial orientation of the surface
- ;
- 'RESETTRANSFORM': begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- sState.oMovableRotationModel->SetProperty, $
- TRANSFORM=sState.initTransformRotation
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of RESETTRANSFORM
-
- ; Toggle off and on the texture mapping.
- ;
- 'TEXTURE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
- j = wsu_ToggleOffOn(sEvent.id)
- case j of
-
- 0: begin
- sState.oSurface->SetProperty, TEXTURE_MAP=OBJ_NEW()
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=1
- end ; of 0
-
- 1: begin
- sState.oSurface->SetProperty, $
- TEXTURE_MAP=sState.oTextureImage
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
- end ; of 1
-
- -1: PRINT, 'Error in wsu_ToggleOffOn/texture.'
-
- endcase
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of TEXTURE
-
- ; Toggle off and on the vertex colors.
- ;
- 'VERTEXCOLOR' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- j = wsu_ToggleOffOn(sEvent.id)
- case j of
- 0: sState.oSurface->SetProperty, VERT_COLORS=0
- 1: sState.oSurface->SetProperty, $
- VERT_COLORS=sState.vertexColors
- -1: PRINT, 'Error in wsu_ToggleOffOn/vertexcolors.'
- endcase
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of VERTEXCOLOR
-
- ; Toggle off and on the hidden points and lines.
- ;
- 'HIDE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- j = wsu_ToggleOffOn(sEvent.id)
- if (j eq -1) then begin
- PRINT, 'Error in wsu_ToggleOffOn/hide.'
- RETURN
- endif
- sState.oSurface->SetProperty, HIDDEN_LINES=j
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of HIDE
-
- ; Toggle between solid and dash linestyles.
- ;
- 'LINESTYLE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- j = wsu_ToggleOffOn(sEvent.id)
- case j of
- 0: sState.oSurface->SetProperty, LINESTYLE=0 ; solid
- 1: sState.oSurface->SetProperty, LINESTYLE=[1,'5555'X] ; dash
- -1: PRINT, 'Error in wsu_ToggleOffOn/linestyle.'
- endcase
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of LINESTYLE
-
- ; Show no skirt.
- ;
- 'SKIRTNONE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- sState.oSurface->SetProperty, SHOW_SKIRT = 0
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SKIRTNONE
-
- ; Set skirt to -0.5.
- ;
- 'SKIRT10' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- sState.oSurface->SetProperty, SKIRT=-0.5, /SHOW_SKIRT
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=0
- WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SKIR10
-
- ; Set skirt to 0.0.
- ;
- 'SKIRT20' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- sState.oSurface->SetProperty, SKIRT=0.0, /SHOW_SKIRT
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=0
- WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SKIR20
-
- ; Set skirt to 0.5.
- ;
- 'SKIRT30' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
- sState.oSurface->SetProperty, SKIRT=0.5, /SHOW_SKIRT
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=1
- WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=0
- WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of SKIR30
-
- ; Set drag quality to low.
- ;
- 'LOW' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- sState.dragq = 0
- WIDGET_CONTROL, sState.wLowButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wMediumButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHighButton, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of LOW
-
- ; Set drag quality to medium.
- ;
- 'MEDIUM' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- sState.dragq = 1
- WIDGET_CONTROL, sState.wLowButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wMediumButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wHighButton, SENSITIVE=1
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of MEDIUM
-
- ; Set drag quality to high.
- ;
- 'HIGH' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- sState.dragq = 2
- WIDGET_CONTROL, sState.wLowButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wMediumButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wHighButton, SENSITIVE=0
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of HIGH
-
- ; Draw only the surface within the tracing
- ; contour (trace mask on),
- ; or draw the whole surface (trace mask on).
- ; Toggle between these 2 options.
- ;
- 'TRACING_MASK' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
-
- if (sState.tracingMode EQ 1) then begin
-
- j = wsu_ToggleOffOn(sEvent.id)
- case j of
- 0: sState.oSurface->SetProperty, TEXTURE_MAP=OBJ_NEW()
- 1: begin
- sState.oTracePolyline->GetProperty, $
- DATA=data, POLYLINE=connectivityList
- sState.oTracingMask->GetProperty, DATA=idata
- mask = BYTARR(400, 400)
- if (connectivityList(0) ge 3) then begin
- ; Get the number of current points minus 1
- ;
- nCurrentPointsM1 = connectivityList(0) - 1
- x = data(0, 0:nCurrentPointsM1) * 10.0
- y = data(1, 0:nCurrentPointsM1) * 10.0
- fill = POLYFILLV(x, y, 400, 400)
- mask(*, *) = 0
- mask(fill) = 255
- endif else begin
- mask(*, *) = 255
- endelse
- idata(*, *, 3) = mask
- sState.oTracingMask->SetProperty, DATA=idata
- sState.oSurface->SetProperty, $
- TEXTURE_MAP=sState.oTracingMask
- end ; of 1
- -1: PRINT, 'Error in wsu_ToggleOffOn/tracingMask.'
- endcase
-
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=1
- textChange = ['reset', 'erase']
- putTips, sState.sText, sState.wText[1], $
- textChange, [1,2]
-
-
- ; Reset the tracing features to its initial status. The
- ; tracing manipulation can be repeated.
- ;
- endif else begin
-
- sState.oSurface->SetProperty, TEXTURE_MAP=OBJ_NEW()
- j = wsu_ToggleOffOn(sState.wTracingModeButton)
- j = wsu_ToggleOffOn(sState.wTracingMaskButton)
- j = wsu_ToggleOffOn(sState.wTracingResetButton)
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wStyleButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTextureButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
- textChange = ['infor', 'instr']
- putTips, sState.sText, sState.wText[1], $
- textChange, [1,2]
- sState.tracingMode = 0
- endelse
-
- sState.oWindow->Draw, sState.oView
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of TRACING_MASK
-
- ; Enable (on) or disable (off) the tracing mode.
- ; Toggle between these 2 options.
- ;
- 'TRACING_MODE' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- j = wsu_ToggleOffOn(sEvent.id)
- if (j eq -1) then begin
- PRINT, 'Error in wsu_ToggleOffOn/tracingMode.'
- RETURN
- endif
- sState.tracingMode = 1
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTextureButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wStyleButton, SENSITIVE=0
- textChange = ['regio', 'right']
- putTips, sState.sText, sState.wText[1], $
- textChange, [1,2]
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of TRACING_MODE
-
- ; Tracing reset erases the tracing lines (res lines).
- ;
- 'TRACING_RESET' : begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
- WIDGET_CONTROL, sEvent.top, /HOURGLASS
- j = wsu_ToggleOffOn(sEvent.id)
- sState.oTracePolyline->GetProperty, POLYLINE=connectivityList
- connectivityList(0) = 0
- connectivityList(1) = -1
- sState.oTracePolyline->SetProperty, $
- POLYLINE=connectivityList
- sState.oWindow->Draw, sState.oView
- sState.tracingMode = 0
- textChange = ['mask1', 'whole']
- putTips, sState.sText, sState.wText[1], $
- textChange, [1,2]
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of TRACING_RESET
-
- ; Handle the event that occurs in the drawing (viewing) area.
- ; These are : expose and mouse button(press, motion, release).
- ;
- 'DRAW': begin
- WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
-
- ; Expose.
- ;
- if (sEvent.type eq 4) then begin
- sState.oWindow->draw, sState.oView
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- RETURN
- endif
-
- ; Handle trackball update
- ;
- bHaveTransform = sState.oTrack->Update(sEvent, TRANSFORM=qmat )
- if (bHaveTransform NE 0) then begin
- sState.oMovableRotationModel->GetProperty, TRANSFORM=t
- mt = t # qmat
- sState.oMovableRotationModel->SetProperty,TRANSFORM=mt
- endif
-
- ; Button press.
- ;
- if (sEvent.type EQ 0) then begin
-
- ; Right button press.
- ;
- if (sEvent.press EQ 4) then begin
- pick = sState.oWindow->PickData(sState.oView, $
- sState.oSurface, [sEvent.x, sEvent.y], dataxyz)
- if (pick ne 0) then begin
- statusString = STRING(dataxyz(0), $
- dataxyz(1),dataxyz(2), $
- FORMAT='("X=", F6.2,' + $
- ' ", Y=",F6.2,", Z=",F6.2)')
- sState.sText.text[7] = statusString
- textChange = ['locat', 'void']
- putTips, sState.sText, sState.wText[1], $
- textChange, [1,2]
- if (sState.tracingMode eq 1) then begin
- wsu_AddTracePoint, sState.oTracePolyline, $
- dataxyz, check
- sState.firstPoint = dataxyz
- if (check eq -1) then begin
- PRINT,'Error in wsu_AddTracePoint/Draw.'
- endif
- sState.oWindow->Draw, sState.oView
- endif
- sState.btndown = 4b
- WIDGET_CONTROL, sState.wDraw, /DRAW_MOTION
- endif else begin
- sState.sText.text[7] ="Data point:In background"
- textChange = ['void']
- putTips, sState.sText, sState.wText[1], $
- textChange, [2]
- endelse
- endif else begin
- sState.btndown = 1b
- sState.oWindow->SetProperty, QUALITY=sState.dragq
- WIDGET_CONTROL, sState.wDraw, /DRAW_MOTION
- endelse
- endif ; ev.typ EQ 0
-
- ; Button motion and tracing mode
- ;
- if ((sEvent.type eq 2) and (sState.btndown eq 4b)) then begin
- pick = sState.oWindow->PickData(sState.oView, $
- sState.oSurface, [sEvent.x, sEvent.y], dataxyz)
- if (pick ne 0) then begin
- statusString = STRING(dataxyz(0), $
- dataxyz(1),dataxyz(2), $
- FORMAT='("X=", F6.2,' + $
- ' ", Y=",F6.2,", Z=",F6.2)')
- sState.sText.text[7] = statusString
- textChange = ['locat', 'void']
- putTips, sState.sText, sState.wText[1], $
- textChange, [1,2]
- if (sState.tracingMode ne 0) then begin
- wsu_AddTracePoint, sState.oTracePolyline, $
- dataxyz, check
- if (check eq -1) then begin
- PRINT,'Error in wsu_AddTracePoint/Draw.'
- endif
- sState.oWindow->Draw, sState.oView
- endif
- endif else begin
- sState.sText.text[7] ="Data point:In background"
- textChange = ['void']
- putTips, sState.sText, sState.wText[1], $
- textChange, [2]
- endelse
- endif
-
- ; Button motion.
- ;
- if ((sEvent.type eq 2) and (sState.btndown eq 1b)) then begin
- if (bHaveTransform) then $
- sState.oWindow->Draw, sState.oView
- endif
-
- ; Button release.
- ;
- if (sEvent.type eq 1) then begin
- if (sState.btndown EQ 1b) then begin
- sState.oWindow->SetProperty, QUALITY=2
- sState.oWindow->Draw, sState.oView
- endif else if ((sState.btndown EQ 4b) $
- AND (sState.tracingmode EQ 1) ) then begin
- wsu_AddTracePoint, sState.oTracePolyline, $
- sState.firstPoint, check
- if (check eq -1) then begin
- PRINT,'Error in wsu_AddTracePoint/Draw.'
- endif
- sState.oWindow->Draw, sState.oView
- sState.tracingMode = 1
- textChange = ['mask1', 'displ']
- putTips, sState.sText, sState.wText[1], $
- textChange, [1,2]
- WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
- WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=1
- WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
- endif
- sState.btndown = 0b
- WIDGET_CONTROL, sState.wDraw, DRAW_MOTION = 0
- endif
- WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
- end ; of DRAW
-
- ; Quit the application.
- ;
- 'QUIT' : begin
- WIDGET_CONTROL, sEvent.top, /DESTROY
- end ; of QUIT
-
- ; Show the information text.
- ;
- 'ABOUT' : begin
- ; Verify that there is only one instance of XDisplayfile
- ;
- if (XREGISTERED('XDisplayFile') ne 0) then return
- XDisplayFile, filepath("surfview.txt", $
- SUBDIR=['examples','demo','demotext']), $
- DONE_BUTTON='Done', $
- TITLE="Surface", $
- GROUP=sEvent.top, WIDTH=55, HEIGHT=14
- end ; of ABOUT
-
- endcase ; of case uval of
-
- end ; of event handler
-
- ;----------------------------------------------------------------------------
- ;
- ; Purpose: Restore the previous color table and
- ; destroy the top objects.
- ;
- pro surfview_Cleanup, $
- wTopBase ; IN: top level base ID.
- WIDGET_CONTROL, wTopBase, GET_UVALUE=sState, /NO_COPY
-
- ; Destroy the top objects
- ;
- OBJ_DESTROY, sState.oView
- OBJ_DESTROY, sState.oTextureImage
- OBJ_DESTROY, sState.oTracingMask
- OBJ_DESTROY, sState.oTracK
- OBJ_DESTROY, sState.oText
- OBJ_DESTROY, sState.oFont
- OBJ_DESTROY, sState.oContainer
-
- ; Restore the color table
- ;
- TVLCT, sState.colorTable
-
- ; Map the group leader base if it exists.
- ;
- if (WIDGET_INFO(sState.groupBase, /VALID_ID)) then $
- WIDGET_CONTROL, sState.groupBase, /MAP
-
- end ; of surfview_Cleanup
-
-
-
- ;----------------------------------------------------------------------------
- ;
- ; Purpose: Display a surface. Show the IDL 5.0 functionalities.
- ;
- pro d_surfview, $
- ALT_FUNC=ALT_FUNC, $ ; IN: (opt) Alternative function : sine dist
- TRANSPARENT=transparent, $ ; IN: (opt) Transparent across a plane
- GROUP=group, $ ; IN: (opt) group identifier
- APPTLB = appTLB ; OUT: (opt) TLB of this application
-
- ; Check the validity of the group identifier
- ;
- ngroup = N_ELEMENTS(group)
- if (ngroup NE 0) then begin
- check = WIDGET_INFO(group, /VALID_ID)
- if (check NE 1) then begin
- print,'Error, the group identifier is not valid'
- print, 'Return to the main application'
- RETURN
- endif
- groupBase = group
- endif else groupBase = 0L
-
-
- ; Set up dimensions of the drawing (viewing) area.
- ;
- device, GET_SCREEN_SIZE=scr
- xdim = scr(0)*0.6
- ydim = xdim*0.8
-
- ; Get the tips.
- ;
- sText = getTips(filepath('surfview.tip', $
- SUBDIR=['examples','demo', 'demotext']) )
-
- ; Get the current color vectors to restore
- ; when this application is exited.
- TVLCT, savedR, savedG, savedB, /GET
-
- ; Build color table from color vectors
- ;
- colorTable = [[savedR],[savedG],[savedB]]
-
- ; Create widgets.
- ;
- if (N_ELEMENTS(group) EQ 0) then begin
- wTopBase = WIDGET_BASE(/COLUMN, XPAD=0, YPAD=0, $
- /TLB_KILL_REQUEST_EVENTS, $
- TLB_FRAME_ATTR=1, MBAR=barBase, $
- TITLE="Surface Objects")
- endif else begin
- wTopBase = WIDGET_BASE(/COLUMN, XPAD=0, YPAD=0, $
- /TLB_KILL_REQUEST_EVENTS, $
- TLB_FRAME_ATTR=1, MBAR=barBase, $
- GROUP_LEADER=group, $
- TITLE="Surface Objects")
- endelse
-
- ; Create the menu bar. It contains the file,
- ; edit, and help buttons.
- ;
- wFileButton = WIDGET_BUTTON(barBase, VALUE = 'File', /MENU)
- wQuitButton = WIDGET_BUTTON(wFileButton, VALUE='Quit', $
- UVALUE='QUIT')
-
- ; Create the menu bar item Edit
- ; that has the shade and style options.
- ;
- wOptionButton = WIDGET_BUTTON(barBase, VALUE = 'Options', /MENU)
-
- ; Select the plot shading.
- ;
- wShadingButton = WIDGET_BUTTON(wOptionButton, $
- VALUE='Shading', UVALUE='SHADING', MENU=1)
-
- wFlatButton = WIDGET_BUTTON(wShadingButton, $
- VALUE='Flat', UVALUE='FLAT')
-
- wGouraudButton = WIDGET_BUTTON(wShadingButton, $
- VALUE='Gouraud', UVALUE='GOURAUD')
-
- ; Select the plot style.
- ;
- wStyleButton = WIDGET_BUTTON(wOptionButton, $
- VALUE='Style', UVALUE='STYLE', /MENU)
-
- wPointButton = WIDGET_BUTTON(wStyleButton, $
- VALUE='Point', UVALUE='POINT')
-
- wWireButton = WIDGET_BUTTON(wStyleButton, $
- VALUE='Wire', UVALUE='WIRE')
-
- wSolidButton = WIDGET_BUTTON(wStyleButton, $
- VALUE='Solid', UVALUE='SOLID')
-
- wRuledXZButton = WIDGET_BUTTON(wStyleButton, $
- VALUE='Ruled XZ', UVALUE='RULEDXZ')
-
- wRuledYZButton = WIDGET_BUTTON(wStyleButton, $
- VALUE='Ruled YZ', UVALUE='RULEDYZ')
-
- wLegoWireButton = WIDGET_BUTTON(wStyleButton, $
- VALUE='Lego Wire', UVALUE='LEGOWIRE')
-
- wLegoSolidButton = WIDGET_BUTTON(wStyleButton, $
- VALUE='Lego Solid', UVALUE='LEGOSOLID')
-
- ; Select the skirt value.
- ;
- wSkirtButton = WIDGET_BUTTON(wOptionButton, $
- VALUE='Skirt', UVALUE='SKIRT', /MENU)
-
- ; Remove the skirt
- ;
- wSkirtNoneButton = WIDGET_BUTTON(wSkirtButton, $
- VALUE='None', UVALUE='SKIRTNONE')
-
- ; Skirt10 is -0.5.
- ;
- wSkirt10Button = WIDGET_BUTTON(wSkirtButton, $
- VALUE='z=-0.5', UVALUE='SKIRT10')
-
- ; Skirt20 is 0.0
- ;
- wSkirt20Button = WIDGET_BUTTON(wSkirtButton, $
- VALUE='z=0.0', UVALUE='SKIRT20')
-
- ; Skirt30 is 0.5
- ;
- wSkirt30Button = WIDGET_BUTTON(wSkirtButton, $
- VALUE='z=0.5', UVALUE='SKIRT30')
-
- ; Set up the drag quality. Low is wire, medium is
- ; polygons, high is smoothed polygons.
- ;
- wDragButton = Widget_Button(wOptionButton, $
- VALUE="Drag Quality", UVALUE='DRAGQ', /MENU)
-
- wLowButton = WIDGET_BUTTON(wDragButton, $
- VALUE='Low', UVALUE='LOW')
-
- wMediumButton = WIDGET_BUTTON(wDragButton, $
- VALUE='Medium', UVALUE='MEDIUM')
-
- wHighButton = WIDGET_BUTTON(wDragButton, $
- VALUE='High', UVALUE='HIGH')
-
- ; Allows to trace a contour on the surface, and
- ; then to display only the surface contained within
- ; that contour.
- ;
- wTracingButton = WIDGET_BUTTON(wOptionButton, $
- VALUE='Tracing', UVALUE='TRACING', /MENU)
-
- wTracingModeButton = WIDGET_BUTTON(wTracingButton, $
- VALUE='Trace Mode (off)', UVALUE='TRACING_MODE')
-
- wTracingMaskButton = WIDGET_BUTTON(wTracingButton, $
- VALUE='Trace Mask (off)', UVALUE='TRACING_MASK')
-
- wTracingResetButton = WIDGET_BUTTON(wTracingButton, $
- VALUE='Trace Reset (off)', UVALUE='TRACING_RESET')
-
- ; Toggle between showing or not showing
- ; the hidden points and lines.
- ;
- wHiddenButton = WIDGET_BUTTON(wOptionButton, $
- VALUE="Hidden (off)", UVALUE='HIDE')
-
- ; Toggle between showing or not showing
- ; the vertices in colors.
- ;
- wVertexButton = WIDGET_BUTTON(wOptionButton, $
- VALUE="Vertex Colored (on )", UVALUE='VERTEXCOLOR')
-
- ; Toggle between showing or not showing
- ; the texture mapping.
- ;
- wTextureButton = WIDGET_BUTTON(wOptionButton, $
- VALUE="Texture Mapping (off)", UVALUE='TEXTURE')
-
- ; Toggle between a solid or dash line style.
- ;
- wLineStyleButton = WIDGET_BUTTON(wOptionButton, $
- VALUE="Line Style (off)", UVALUE='LINESTYLE')
-
- ; Create the menu bar item Edit
- ; that has the shade and style options.
- ;
- wViewButton = WIDGET_BUTTON(barBase, VALUE = 'View', /MENU)
-
- wAnimateButton = WIDGET_BUTTON(wViewButton, $
- VALUE="Animate", UVALUE='ANIMATE')
-
- wResetButton = WIDGET_BUTTON(wViewButton, $
- VALUE="Reset Orientation", UVALUE='RESETTRANSFORM')
-
- ; Create the menu bar item help that contains the about button.
- ;
- wHelpMenu = WIDGET_BUTTON(barBase, VALUE='About', $
- /HELP, /MENU)
-
- wAboutButton = WIDGET_BUTTON(wHelpMenu, $
- VALUE='About Surface Objects', UVALUE='ABOUT')
-
-
- ; Create a sub base of the top base (wBase).
- ;
- wSubBase = WIDGET_BASE(wTopBase, COLUMN=2)
-
- ; Create the left Base that contains the functionality buttons.
- ; Here the only button is to animate the object.
- ;
- wLeftbase = WIDGET_BASE(wSubBase,/BASE_ALIGN_CENTER, $
- COLUMN=1)
-
- wMinMaxBase = WIDGET_BASE(wLeftBase, $
- /COLUMN, YPAD=10)
-
- wMinMaxLabel = WIDGET_LABEL(wMinMaxBase, $
- VALUE='Data Range')
-
- minValue = -0.41
- minString ='Minimum: ' + STRING(minValue, $
- FORMAT='(f5.2)')
- wMinLabel = WIDGET_LABEL(wMinMaxBase, $
- VALUE=minString)
-
- wMinSlider = WIDGET_SLIDER(wMinMaxBase, $
- MINIMUM=-41, $
- MAXIMUM=25, VALUE=-41, $
- /SUPPRESS_VALUE, $
- UVALUE='SHOWMIN')
-
- maxValue = 1.01
- maxString ='Maximum: ' + STRING(maxValue, $
- FORMAT='(f5.2)')
- wMaxLabel = WIDGET_LABEL(wMinMaxBase, $
- VALUE=maxString)
-
- wMaxSlider = WIDGET_SLIDER(wMinMaxBase, $
- MINIMUM=25, $
- MAXIMUM=101, VALUE=101, $
- /SUPPRESS_VALUE, $
- UVALUE='SHOWMAX')
-
- wScalingBase = WIDGET_BASE(wLeftBase, $
- /COLUMN, YPAD=10)
-
- percent = 100
- scalingString = 'Scaling : ' + STRING(percent, $
- FORMAT='(f5.1)') + ' %'
- wScalingLabel = WIDGET_LABEL(wScalingBase, $
- VALUE=scalingString)
-
- wScalingSlider = WIDGET_SLIDER(wScalingBase, $
- MINIMUM=0, $
- MAXIMUM=50, VALUE=25, $
- /SUPPRESS_VALUE, $
- UVALUE='SCALING')
-
- ; Create the right Base that has the drawing area.
- ;
- wRightbase = WIDGET_BASE(wSubBase, COLUMN=1)
-
- wDraw = WIDGET_DRAW(wRightBase, $
- GRAPHICS_LEVEL=2, $
- XSIZE=xdim, YSIZE=ydim, /BUTTON_EVENTS, $
- UVALUE='DRAW', RETAIN=0, /EXPOSE_EVENT)
-
- ; Create tips texts.
- ;
- wStatusBase = WIDGET_BASE(wTopBase, MAP=0, /ROW)
-
- nWidgets = 2
- wText = LONARR(nWidgets)
- widTips, wStatusBase, sText.text, XSIZE=36, $
- YSIZE=3, NWIDGETS=nWidgets, wText
-
- ; Now the widget have been created, realize it.
- ;
- WIDGET_CONTROL, wTopBase, /REALIZE
-
- ; Returns the top level base to the APPTLB keyword.
- ;
- appTLB = wtopBase
-
- ; Size the tips widgets.
- ;
- sizeTips, wTopBase, wText, wStatusBase
-
- ; Grab the window id of the drawable.
- ;
- WIDGET_CONTROL, wDraw, GET_VALUE=oWindow
-
- WIDGET_CONTROL, wTopBase, SENSITIVE=0
-
-
- bias = -0.5
- ; Compute viewplane rectangle based on aspect ratio.
- ;
- aspect = float(xdim)/float(ydim)
- if (aspect > 1) then $
- myview = [(1.0-aspect)/2.0+bias, 0.0+bias, aspect, 1.0] $
- else $
- myview = [0.0+bias, (1.0-(1.0/aspect))/2.0+bias, 1.0, (1.0/aspect)]
-
- ; Create view object.
- ;
- oView = OBJ_NEW('idlgrview', PROJECTION=2, EYE=3, $
- ZCLIP=[1.5,-1.5], VIEW=myview, COLOR=[0, 0, 0])
-
- ; Make the text location to be centered.
- ;
- textLocation = [myview(0)+0.5*myview(2), myview(1)+0.5*myview(3)]
-
- ; Create and display the PLEASE WAIT text.
- ;
- oFont = OBJ_NEW('IDLgrFont', 'Helvetica', SIZE=18)
- oText = OBJ_NEW('IDLgrText', $
- 'Starting up Please wait...', $
- ALIGN=0.5, $
- LOCATION=textLocation, $
- COLOR=[255,255,0], FONT=oFont)
-
- ; Create model.
- ;
- oTopModel = obj_new('idlgrmodel')
- oMovableModel = OBJ_NEW('idlgrmodel')
- oMovableScalingModel = OBJ_NEW('idlgrmodel')
- oMovableRotationModel = OBJ_NEW('idlgrmodel')
- oTopModel->Add, oMovableModel
- oMovableModel->Add, oMovableScalingModel
- oMovableScalingModel->Add, oMovableRotationModel
-
- ; Place the model in the view.
- ;
- oView->Add, oTopModel
-
- ; Scale the top model to fit the viewing area.
- ;
- sct = 0.6
- oTopModel->Scale, sct, sct, sct
-
- otopModel->Add, oText
-
- ; Draw the starting up screen.
- ;
- oWindow->Draw, oView
-
- ; Surface data is a Besel function.
- ;
- if (N_ELEMENTS(ALT_FUNC) ne 0) then begin
- a = DIST(40)
- a = 8.0*a/MAX(a)
- z = SIN(a)
- endif else begin
- z = BESELJ(SHIFT(DIST(40),20,20)/2,0)
- endelse
-
-
- ; Compute coordinate conversion to normalize.
- ;
- sz = SIZE(z)
- maxx = sz(1) - 1
- maxy = sz(2) - 1
- maxz = MAX(z, MIN=minz)
- xs = [0+bias, 1.0/maxx]
- ys = [0+bias, 1.0/maxy]
- minz2 = minz - 1
- maxz2 = maxz + 1
- zs = [-minz2/(maxz2-minz2)+bias, 1.0/(maxz2-minz2)]
-
- ; For height-fields, use the following vertex colors.
- ;
- vertexColors = BYTARR(3, 40*40, /NOZERO)
- cbins= $
- [[255, 0, 0],$
- [255, 85, 0],$
- [255, 170, 0],$
- [255, 255, 0],$
- [170, 255, 0],$
- [85, 255, 0],$
- [0, 255, 0]]
-
- zi = ROUND((z - minz)/(maxz-minz) * 6.0)
- vertexColors(*, *) = cbins(*, zi)
-
- imagefile = filepath('dave.gif', SUBDIR=['examples','demo','demodata'])
- void = FINDFILE(imagefile, COUNT=nFile)
- if (nFile gt 0)then begin
- READ_GIF, imagefile, $
- plane, red, green, blue
- plane = red(plane)
- sizePlane = SIZE(plane)
- idata = BYTARR(sizePlane(1), sizePlane(2), 2)
- if (N_ELEMENTS(transparent) ne 0) then begin
- idata(*, *, 0) = plane
- ; Compute alpha
- ;
- t = where( plane eq 255, nPoints)
- plane(*) = 255
- if (nPoints ne -1) then begin
- plane(t) = 0
- endif
- idata(*, *, 1) = plane
- oTextureImage = OBJ_NEW('idlgrImage', idata, $
- INTERLEAVE=2)
- endif else begin
- oTextureImage = OBJ_NEW('idlgrImage', plane)
- endelse
-
- endif else begin
- idata = BYTSCL(DIST(100))
- oTextureImage = OBJ_NEW('idlgrImage', idata)
- endelse
-
- ; Create the tracing objects.
- ;
- workData = BYTARR(400, 400, 4)
- workData(*, *, *) = 255
- oTracingMask = OBJ_NEW('idlgrImage', workData, INTERLEAVE=2)
- tracingData = FLTARR(3, 1024)
- tracingConnectivityList = LONARR(1024)
- tracingConnectivityList(0) = 0
- tracingConnectivityList(1) = -1
-
- ; Create polyline object in the same space as the surface.
- ;
- oTracePolyline = OBJ_NEW('idlgrPolyline', $
- tracingData, POLYLINES=tracingConnectivityList, $
- COLOR=[255, 0, 0], $
- XCOORD_CONV=xs, YCOORD_CONV=ys, ZCOORD_CONV=zs, $
- THICK=3)
- oMovableRotationModel->Add, oTracePolyline
-
- ; Create surface object.
- ;
- oSurface = OBJ_NEW('idlgrSurface', $
- z, STYLE=2, $
- SHADING=1, $
- COLOR=[230, 230, 230], BOTTOM=[64, 192, 128], $
- XCOORD_CONV=xs, YCOORD_CONV=ys, ZCOORD_CONV=zs)
-
- oMovableRotationModel->Add, oSurface
-
- ; Create a light.
- ;
- oSunLight = OBJ_NEW('IDLgrLight', LOCATION=[1.5, 0, 1], $
- TYPE=1, INTENSITY=0.5)
- otopModel->Add, oSunLight
- oSunLight = OBJ_NEW('IDLgrLight', TYPE=0, $
- INTENSITY=0.75)
- otopModel->Add, oSunLight
-
- ; Rotate to standard view for first draw.
- ;
- oMovableRotationModel->Rotate, [1, 0, 0], -90
- oMovableRotationModel->Rotate, [0, 1, 0], 30
- oMovableRotationModel->Rotate, [1, 0, 0], 30
-
- ; Add the trackball object for interactive change
- ; of the scene orientation
- ;
- oTrack = OBJ_NEW('Trackball', [xdim/2.0, ydim/2.0], xdim/2.0)
-
- oContainer = OBJ_NEW('IDLgrContainer')
- oContainer->Add, oView
- oContainer->Add, oTrack
-
- oMovableRotationModel->GetProperty, TRANSFORM=initTransformRotation
- oMovableScalingModel->GetProperty, TRANSFORM=initTransformScaling
-
- ; Create the sState
- ;
- sState = { $
- ColorTable: colorTable, $
- Center: xdim/2., $ ; Center of view
- Radius: ydim/2, $ ; Radius
- XSizeData: sz(1), $ ; x data dimension
- YSizeData: sz(2), $ ; x data dimension
- Btndown: 0b, $ ; Botton down flag
- Pt0: FLTARR(3), $ ; Initial point
- Pt1: FLTARR(3), $ ; Final point
- Dragq: 0, $ ; Drag quality
- FirstPoint: FLTARR(3), $
- WDraw: wDraw, $ ; Widget draw
- OTrack: oTrack, $
- OContainer: oContainer, $
- OTopModel: oTopModel, $ ; Top model
- OMovableModel: oMovableModel, $ ; Movable models
- OMovableScalingModel: oMovableScalingModel, $
- OMovableRotationModel: oMovableRotationModel, $
- OSurface: oSurface, $ ; Surface object
- InitTransformScaling: initTransformScaling, $
- InitTransformRotation: initTransformRotation, $
- OView: oView, $ ; Main view object
- OFont: oFont, $ ; Font object
- OText: oText, $ ; Text object
- VertexColors: vertexColors, $ ; Vertex colors(RGB)
- OTracePolyline: oTracePolyline, $ ; Trace object
- OTracingMask: oTracingMask, $ ; Tracing mask object
- OTextureImage: oTextureImage, $ ; Texture image object
- TracingMode: 0, $ ; Tracing mode 0=off,1=on
- OWindow: oWindow, $ ; Window object
- WTopBase : wTopBase, $ ; Top level base
- WFlatButton : wFlatButton, $ ; Shading options
- WGouraudButton : wGouraudButton, $
- WStyleButton: wStyleButton, $
- WPointButton : wPointButton, $ ; Styles options
- WWireButton : wWireButton, $
- WSolidButton : wSolidButton, $
- WRuledXZButton : wRuledXZButton, $
- WRuledYZButton : wRuledYZButton, $
- WLegoWireButton : wLegoWireButton, $
- WLegoSolidButton : wLegoSolidButton, $
- WSkirtNoneButton : wSkirtNoneButton, $ ; Skirt options
- WSkirt10Button : wSkirt10Button, $
- WSkirt20Button : wSkirt20Button, $
- WSkirt30Button : wSkirt30Button, $
- WLowButton : wLowButton, $ ; Drag quality options
- WMediumButton : wMediumButton, $
- WHighButton : wHighButton, $
- WMinSlider: wMinSlider, $ ; Sliders IDs
- WMaxSlider: wMaxSlider, $
- WMinLabel: wMinLabel, $ ; Sliders label IDs
- WMaxLabel: wMaxLabel, $
- WScalingSlider: wScalingSlider, $
- WScalingLabel: wScalingLabel, $
- WTracingButton : wTracingButton, $ ; Tracing options
- WTracingModeButton : wTracingModeButton, $
- WTracingMaskButton : wTracingMaskButton, $
- WTracingResetButton : wTracingResetButton, $
- WHiddenButton : wHiddenButton, $ ; Hidden option
- WTextureButton : wTextureButton, $ ; Texture mapping option
- WText: wText, $ ; Widget text idS for tips
- SText: sText, $ ; Text structure for tips
- WLineStyleButton : wLineStyleButton, $ ; Linestyle option
- groupBase: groupBase $ ; Base of Group Leader
- }
-
- ; Desensitize the defaults buttons.
- ;
- WIDGET_CONTROL, wGouraudButton, SENSITIVE=0
- WIDGET_CONTROL, wSolidButton, SENSITIVE=0
- WIDGET_CONTROL, wSkirtNoneButton, SENSITIVE=0
- WIDGET_CONTROL, wLowButton, SENSITIVE=0
- WIDGET_CONTROL, wHiddenButton, SENSITIVE=0
- WIDGET_CONTROL, wLineStyleButton, SENSITIVE=0
- WIDGET_CONTROL, wTracingMaskButton, SENSITIVE=0
- WIDGET_CONTROL, wTracingResetButton, SENSITIVE=0
-
- WIDGET_CONTROL, wTopBase, SET_UVALUE=sState, /NO_COPY
-
- WIDGET_CONTROL, wTopBase, /HOURGLASS
-
- ; Put the color on the surface.
- ;
- oSurface->SetProperty, VERT_COLORS=vertexColors
-
- otopModel->Remove, oText
- oWindow->Draw, oView
-
- WIDGET_CONTROL, wTopBase, SENSITIVE=1
-
- XMANAGER, 'd_surfview', wTopBase, EVENT_HANDLER='surfview50_event', $
- CLEANUP='surfview_Cleanup', /NO_BLOCK
-
- end
-